//
// Created by gogoqiu on 2022/1/12.
//

#include <stdio.h>
#include <uuid/uuid.h>
#include <wx/wx.h>

int gen_uuid( char* buf )
{
    uuid_t uu;
    int i , j = 0;
    uuid_generate ( uu );
    //printf( "%08X\n", buf );
    for ( i = 0; i < 4; i++ ) {
        //printf( "%08X\n", uu[i] );
        //printf( "%02X\n", uu[i] );
        sprintf ( buf+j+i*2, "%02x", uu[i] );
    }
    //j++;//i++;
    //printf( "%s\n", buf );
    //sprintf( buf+(i+1)*2+j, "%s", "----" );
    sprintf( buf+i*2, "-" );
    j++;
    //printf( "%s\n", buf );
    for ( i = 4; i < 6; i++ ) {
        //printf( "%02X\n", uu[i] );
        sprintf ( buf+j+i*2, "%02x", uu[i] );
    }
    sprintf( buf+i*2+j, "-" );
    j++;
    //printf( "%s\n", buf );
    for ( i = 6; i < 8; i++ ) {
        sprintf ( buf+j+i*2, "%02x", uu[i] );
    }
    sprintf( buf+i*2+j, "-" );
    j++;
    //printf( "%s\n", buf );
    for ( i = 8; i < 10; i++ ) {
        sprintf ( buf+j+i*2, "%02x", uu[i] );
    }
    sprintf( buf+i*2+j, "-" );
    j++;
    //printf( "%s\n", buf );
    for ( i = 10; i < 16; i++ ) {
        sprintf ( buf+j+i*2, "%02x", uu[i] );
    }
    //printf ( "\n" );
    return 0;
}

wxString gen_uuid_string(){
    /*
    uuid_t uu;
    int i , j = 0;
    uuid_generate ( uu );
    wxString tmp;
    for ( i = 0; i < 4; i++ ) {
        tmp.sprintf("%02x", uu[i] );
    }
    tmp.sprintf( "%02x", uu[i], uu[i], uu[i], uu[i] );
     */
    wxString tmp;
    char buf[33] = {0};
    gen_uuid( buf );
    tmp = buf;
    return tmp;
}